package com.heima.minio.test;

import com.heima.file.service.FileStorageService;
import io.minio.errors.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@SpringBootTest
public class MinIOTest2 {

    @Autowired
    private FileStorageService fileStorageService;

    @Test
    public void testUpdateImgFile() throws ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        try {
            FileInputStream fileInputStream = new FileInputStream("C:\\Users\\Longli\\Desktop\\临时文件\\ae8bcdac5c5c591a1248d5c8605d84a5.jpg");
            String filePath = fileStorageService.uploadImgFile("", "ae8bcdac5c5c591a1248d5c8605d84a5.jpg", fileInputStream);
            System.out.println(filePath);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }


}